import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { list as channelList } from '../channel/Channel.api';
import dayjs from "dayjs";
export const columns: BasicColumn[] = [
  {
    title: '手机号',
    dataIndex: 'mobile',
  },
  // {
  //   title: '年龄',
  //   dataIndex: 'ageGroup',
  // },
  {
    title: '渠道',
    dataIndex: 'channel',
  },
  // {
  //   title: 'unionId',
  //   dataIndex: 'unionId',
  // },
  // {
  //   title: 'openId',
  //   dataIndex: 'openId',
  // },
  {
    title: '加入时间',
    dataIndex: 'joinedDate',
  },
  // {
  //   title: '更新日期',
  //   dataIndex: 'updatedDate',
  // },
  {
    title: '是否允许支付',
    dataIndex: 'allowPaid',
    customRender:({record:{allowPaid}})=>{
      return  allowPaid == 1?'是':'否'
    }
  },
  // {
  //   title: '支付订单号',
  //   dataIndex: 'payOrderId',
  // },
  // {
  //   title: '商户订单号',
  //   dataIndex: 'mchOrderNo',
  // },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '渠道',
    field: 'channel',
    component: 'ApiSelect',
    componentProps: {
      api: channelList,
      resultField: 'records',
      // use name as label
      labelField: 'name',
      // use id as value
      valueField: 'id',
      // not request untill to select
      immediate: false,
    },
    colProps: { span: 6 },
  },
  {
    label: '是否支付',
    field: 'allowPaid',
    component: "Select",
    componentProps: {
      options: [
        {value: null,label:'全部'},
        {value: 1,label:'是'},
        {value: 0,label:'否'}
      ]
    },
    colProps: { span: 4 },
  },
  {
    label: '加入日期',
    field: 'dateRange',
    component: 'RangePicker',
    componentProps: {
      showTime: { defaultValue: dayjs('00:00:00', 'HH:mm:ss') },
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    colProps: { span: 8 },
  },
];

export const formSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  { label: '', field: 'id', component: 'Input', show: false },
  {
    label: '手机号',
    field: 'mobile',
    component: 'Input',
  },
  // {
  //   label: '年龄',
  //   field: 'ageGroup',
  //   component: 'Input',
  // },
  {
    label: '渠道',
    field: 'channel',
    component: 'ApiSelect',
    componentProps: {
      api: channelList,
      resultField: 'records',
      // use name as label
      labelField: 'name',
      // use id as value
      valueField: 'id',
      // not request untill to select
      immediate: false,
      onChange: (e) => {
        console.log('selected:', e);
      },
      // atfer request callback
      onOptionsChange: (options) => {
        console.log('get options', options.length, options);
      },
    },
  },
  // {
  //   label: 'unionId',
  //   field: 'unionId',
  //   component: 'Input',
  // },
  // {
  //   label: 'openId',
  //   field: 'openId',
  //   component: 'Input',
  // },
  {
    label: '加入时间',
    field: 'joinedDate',
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD HH:mm:ss'
    }
  },
  // {
  //   label: '更新日期',
  //   field: 'updatedDate',
  //   component: 'Input',
  // },
  {
    label: '是否允许支付',
    field: 'allowPaid',
    component: 'Switch',
    componentProps: {
      valueField: 'allowPaid'
    }
  },
  // {
  //   label: '支付订单号',
  //   field: 'payOrderId',
  //   component: 'Input',
  // },
  // {
  //   label: '商户订单号',
  //   field: 'mchOrderNo',
  //   component: 'Input',
  // },
];
